package com.example.demo.config;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

@Component
@Primary
public class SwaggerResourcesConfig implements SwaggerResourcesProvider{

	    @Override
		public List<SwaggerResource> get() {
			// TODO Auto-generated method stub
			List<SwaggerResource> resources = new ArrayList<SwaggerResource>();
			resources.add(swaggerResource("图书管理系统示例1.2", "/v2/api-docs", "1.2.0.1"));
			resources.add(swaggerResource("图书管理系统示例1.0", "/v1/api-docs", "1.0.0.3"));
			return resources;
		}
		
		private SwaggerResource swaggerResource(String name, String location, String version) {
			SwaggerResource swaggerResource = new SwaggerResource();
	        swaggerResource.setName(name);
	        swaggerResource.setLocation(location);
	        swaggerResource.setSwaggerVersion(version);
	        return swaggerResource;     
		}
	
}
